package com.ccut.lc.service.Impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.ccut.lc.dao.ProductListMapper;
import com.ccut.lc.model.Product;
import com.ccut.lc.model.ProductType;
import com.ccut.lc.model.QueryVo;
import com.ccut.lc.service.ProductListService;
import com.ccut.lc.utils.Page;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


@Service
public class ProductListServiceImpl implements ProductListService {
	@Resource
	private ProductListMapper productListMapper;


	@Override
	public void addProduct(Product pl) {
		productListMapper.addProduct(pl);
	}

	@Override
	public Page<Product> selProductList(QueryVo queryVo) {
		queryVo.setStart((queryVo.getPage()-1)*queryVo.getRows());
		List<Product> list = productListMapper.selProductList(queryVo);
		int total = productListMapper.getTotal(queryVo);
		Page<Product> page = new Page<>(total,queryVo.getPage(),queryVo.getRows(),list);
		return page;
	}

	@Override
	public int getTotal(QueryVo queryVo) {
		return productListMapper.getTotal(queryVo);
}

	@Override
	public Product findProductByID(Integer id) {
		return productListMapper.findProductById(id);
	}

	@Override
	public List<ProductType>  findProductType() {
		return productListMapper.findProductType();
	}

	@Override
	public void updateProduct(Product product) {
		productListMapper.updateProduct(product);
	}

	@Override
	public void deleteProduct(Integer id) {
		productListMapper.delProduct(id);
	}
}
